/*
 * GestioneDati.java
 *
 * Created on 6 aprile 2007, 22.00
 */

package tlApp;

import fnUtils.IdDes;
import fnUtils.SQLUtils;
import java.awt.event.KeyEvent;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.DefaultListModel;


/**
 *
 * @author  franic
 */

public class GestioneDati extends javax.swing.JFrame {
    public static String nomeTab;
    DefaultListModel listModel = new DefaultListModel();
    boolean ricercaFigli = false;
    int fkEvento;
    int chkEN = 0;
    int chkLvl = 0;
    
    /**
     * Creates new form GestioneDati
     */
    public GestioneDati() {
        initComponents();
    }
    
    public GestioneDati(String ricerca) {
        initComponents();
        ricercaFigli = false;
        txtRicerca.setText(ricerca);
        refreshLista();
    }
    
    public GestioneDati(String ricerca, int fkEvento) {
        initComponents();
        ricercaFigli = true;
        this.fkEvento = fkEvento;
        txtRicerca.setText(ricerca);
        ricercaFigli(fkEvento);
    }
    
        private void refreshLista() {
        ExecSQL.getConn();
        listModel.removeAllElements();
        lstRicerca.setModel(listModel);
        ResultSet rs;
        lblMsg.setText("");
        setChk();
        rs = ExecSQL.ricercaEventi(txtRicerca.getText(), "evento", 
                chkEN, chkLvl, 0);
        try {
            if (rs.next()) {
                do  {
                    IdDes inTab = new IdDes(rs.getInt(1), 
                            SQLUtils.fromDB(rs.getString(2)));
                    listModel.addElement(inTab);
                }  while (rs.next());
                ExecSQL.theConn.close();
            }    else {
                lblMsg.setText("Nessun risultato della ricerca");
                butFigli.setVisible(false);
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
        txtRicerca.grabFocus();
    }
    
    private void setChk() {
        chkLvl = 0;
        chkEN = 0;
        if (chkLivello.isSelected()) {
            chkLvl += 1;
        }
        if (chkEventi.isSelected()) {
            chkEN += 1;
        }
        if (chkNote.isSelected()) {
            chkEN += 2;
        }
        if (chkEN == 0) {
            chkEN = 1;
            chkEventi.setSelected(true);
        }
    }
    
    private void ricercaFigli(int fkEvento) {
        ResultSet rs;
        setChk();
        rs = ExecSQL.ricercaEventi(txtRicerca.getText(), "evento", 
                chkEN, chkLvl, fkEvento);
        try {
            if (rs.next()) {
                listModel.removeAllElements();
                lstRicerca.setModel(listModel);
                do {
                    IdDes inTab = new IdDes(rs.getInt(1), 
                            SQLUtils.fromDB(rs.getString(2)));
                    listModel.addElement(inTab);
                } while (rs.next());
                
            } else {
                lblMsg.setText("Nessun risultato della ricerca");
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
        txtRicerca.grabFocus();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jPanel1 = new javax.swing.JPanel();
        butCategoria = new javax.swing.JButton();
        butZona = new javax.swing.JButton();
        butTipo = new javax.swing.JButton();
        butCaratter = new javax.swing.JButton();
        butExit = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        txtRicerca = new javax.swing.JTextField();
        scrRicerca = new javax.swing.JScrollPane();
        lstRicerca = new javax.swing.JList();

        chkEventi = new javax.swing.JCheckBox();
        chkNote = new javax.swing.JCheckBox();
        butAdd = new javax.swing.JButton();
        butEdit = new javax.swing.JButton();
        butDelete = new javax.swing.JButton();
        butCerca = new javax.swing.JButton();
        lblMsg = new javax.swing.JLabel();
        butFigli = new javax.swing.JButton();
        butFigli.setVisible(false);
        chkLivello = new javax.swing.JCheckBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Timeline - Gestione dati");
        setAlwaysOnTop(true);
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowActivated(java.awt.event.WindowEvent evt) {
                formWindowActivated(evt);
            }
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
            public void windowDeiconified(java.awt.event.WindowEvent evt) {
                formWindowDeiconified(evt);
            }
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });
        addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                formKeyPressed(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Gestione dati ausiliari"));
        butCategoria.setText("Categoria");
        butCategoria.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                butCategoriaActionPerformed(evt);
            }
        });

        butZona.setText("Zona");
        butZona.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                butZonaActionPerformed(evt);
            }
        });

        butTipo.setText("Tipo");
        butTipo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                butTipoActionPerformed(evt);
            }
        });

        butCaratter.setText("Caratter.");
        butCaratter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                butCaratterActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(butCategoria)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(butZona)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(butTipo)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(butCaratter)
                .addContainerGap(28, Short.MAX_VALUE))
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {butCaratter, butCategoria, butTipo, butZona});

        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(butCategoria)
                    .addComponent(butZona)
                    .addComponent(butTipo)
                    .addComponent(butCaratter))
                .addContainerGap())
        );

        butExit.setText("Exit");
        butExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                butExitActionPerformed(evt);
            }
        });

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Gestione eventi"));
        jLabel1.setText("Ricerca");
        jLabel1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabel1MouseClicked(evt);
            }
        });

        txtRicerca.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtRicercaKeyPressed(evt);
            }
        });

        lstRicerca.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        lstRicerca.setFixedCellWidth(1);
        lstRicerca.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lstRicercaMouseClicked(evt);
            }
        });
        lstRicerca.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                lstRicercaValueChanged(evt);
            }
        });

        scrRicerca.setViewportView(lstRicerca);

        chkEventi.setSelected(true);
        chkEventi.setText("eventi");
        chkEventi.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        chkEventi.setMargin(new java.awt.Insets(0, 0, 0, 0));

        chkNote.setText("note");
        chkNote.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        chkNote.setMargin(new java.awt.Insets(0, 0, 0, 0));

        butAdd.setText("Add");
        butAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                butAddActionPerformed(evt);
            }
        });

        butEdit.setText("Show/Edit");
        butEdit.setEnabled(false);
        butEdit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                butEditActionPerformed(evt);
            }
        });

        butDelete.setText("Delete");
        butDelete.setEnabled(false);
        butDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                butDeleteActionPerformed(evt);
            }
        });

        butCerca.setText("Cerca");
        butCerca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                butCercaActionPerformed(evt);
            }
        });

        butFigli.setText("Trova figli");
        butFigli.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                butFigliActionPerformed(evt);
            }
        });

        chkLivello.setSelected(true);
        chkLivello.setText("solo 1^ livello");
        chkLivello.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        chkLivello.setMargin(new java.awt.Insets(0, 0, 0, 0));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblMsg, javax.swing.GroupLayout.PREFERRED_SIZE, 333, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtRicerca, javax.swing.GroupLayout.DEFAULT_SIZE, 228, Short.MAX_VALUE))
                            .addComponent(scrRicerca, javax.swing.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(butCerca, javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
                                .addComponent(chkEventi)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(chkNote))
                            .addComponent(chkLivello, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(butAdd, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(butDelete, javax.swing.GroupLayout.DEFAULT_SIZE, 74, Short.MAX_VALUE)
                                .addComponent(butEdit))
                            .addComponent(butFigli, javax.swing.GroupLayout.Alignment.LEADING))))
                .addContainerGap())
        );

        jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {butAdd, butCerca, butDelete, butEdit, butFigli});

        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(butCerca)
                    .addComponent(txtRicerca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(chkEventi)
                            .addComponent(chkNote))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(chkLivello)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(butAdd)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(butEdit)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(butDelete)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(butFigli))
                    .addComponent(scrRicerca, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblMsg, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(butExit, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(butExit)
                .addContainerGap())
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    private void lstRicercaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lstRicercaMouseClicked
        Evento evento;
        if (evt.getClickCount() == 2) {
            int n = ((IdDes)lstRicerca.getSelectedValue()).getId();
            evento = ExecSQL.readEvento(n);
            new GestioneGrafica(n,evento,txtRicerca.getText()).setVisible(true);
            setVisible(false);
            dispose();
        }
    }//GEN-LAST:event_lstRicercaMouseClicked
    
    private void jLabel1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel1MouseClicked
        txtRicerca.setText("");
        txtRicerca.grabFocus();
        ricercaFigli = false;
    }//GEN-LAST:event_jLabel1MouseClicked
    
    private void butFigliActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butFigliActionPerformed
        if (lstRicerca.getSelectedValue() == null) {
            lblMsg.setText("Selezionare una riga");
        } else {
            fkEvento = ((IdDes)lstRicerca.getSelectedValue()).getId();
            String s = lstRicerca.getSelectedValue().toString();
            ricercaFigli(fkEvento);
            ricercaFigli = true;
            txtRicerca.grabFocus();
            butFigli.setVisible(false);
        }
    }//GEN-LAST:event_butFigliActionPerformed
    
    private void lstRicercaValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstRicercaValueChanged
        if (!listModel.isEmpty() && lstRicerca.getSelectedValue() != null) {
            int n = ((IdDes)lstRicerca.getSelectedValue()).getId();
            if (ExecSQL.esistonoFigli(n)) {
                butFigli.setVisible(true);
                butDelete.setEnabled(false);
            } else {
                butFigli.setVisible(false);
                butDelete.setEnabled(true);
            }
            butEdit.setEnabled(true);
        }
    }//GEN-LAST:event_lstRicercaValueChanged
    
    private void butEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butEditActionPerformed
        Evento evento;
        if (lstRicerca.getSelectedValue() == null) {
            lblMsg.setText("Selezionare una riga");
        } else {
            int n = ((IdDes)lstRicerca.getSelectedValue()).getId();
            evento = ExecSQL.readEvento(n);
            new GestioneEvento(n,evento,txtRicerca.getText(),1).setVisible(true);
            setVisible(false);
            dispose();
        }
    }//GEN-LAST:event_butEditActionPerformed
    
    private void butAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butAddActionPerformed
        new GestioneEvento(0,null,txtRicerca.getText(),1).setVisible(true);
        setVisible(false);
        dispose();
    }//GEN-LAST:event_butAddActionPerformed
    
    private void butDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butDeleteActionPerformed
        boolean rcOK;
        if (lstRicerca.getSelectedValue() == null) {
            lblMsg.setText("Selezionare una riga");
        } else {
            int n = ((IdDes)lstRicerca.getSelectedValue()).getId();
            rcOK = ExecSQL.deleteTab("evento", n);
            if (rcOK) {
                refreshLista();
                lblMsg.setText("Delete OK");
            } else {
                lblMsg.setText("Delete KO");
            }
        }
        butFigli.setVisible(false);
        butAdd.setEnabled(true);
        butEdit.setEnabled(false);
        butDelete.setEnabled(false);
    }//GEN-LAST:event_butDeleteActionPerformed
    
    private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated
        txtRicerca.grabFocus();
    }//GEN-LAST:event_formWindowActivated
    
    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        txtRicerca.grabFocus();
    }//GEN-LAST:event_formWindowOpened
    
    private void formWindowDeiconified(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowDeiconified
        txtRicerca.grabFocus();
    }//GEN-LAST:event_formWindowDeiconified
    
    private void butCercaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butCercaActionPerformed
        refreshLista();
        butFigli.setVisible(false);
        butAdd.setEnabled(true);
        butEdit.setEnabled(false);
        butDelete.setEnabled(false);
    }//GEN-LAST:event_butCercaActionPerformed
    
    private void txtRicercaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtRicercaKeyPressed
        switch (evt.getKeyCode()) {
            case KeyEvent.VK_ENTER: {
                butCerca.doClick();
                break;
            }
            case KeyEvent.VK_ESCAPE: {
                butExit.doClick();
                break;
            }
            default:
                ricercaFigli = false;
        }
    }//GEN-LAST:event_txtRicercaKeyPressed

    private void formKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyPressed
        switch (evt.getKeyCode()) {
            case KeyEvent.VK_ESCAPE: {
                butExit.doClick();
                break;
            }
        }
    }//GEN-LAST:event_formKeyPressed
    
    private void butZonaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butZonaActionPerformed
        nomeTab="zona";
        new GestioneLookUp2().setVisible(true);
        setVisible(false);
        dispose();
    }//GEN-LAST:event_butZonaActionPerformed
    
    private void butCategoriaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butCategoriaActionPerformed
        nomeTab="categoria";
        new GestioneLookUp2().setVisible(true);
        setVisible(false);
        dispose();
    }//GEN-LAST:event_butCategoriaActionPerformed
    
    private void butCaratterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butCaratterActionPerformed
        nomeTab="caratteristica";
        new GestioneLookUp1().setVisible(true);
        setVisible(false);
        dispose();
    }//GEN-LAST:event_butCaratterActionPerformed
    
    private void butTipoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butTipoActionPerformed
        nomeTab="tipo";
        new GestioneLookUp1().setVisible(true);
        setVisible(false);
        dispose();
    }//GEN-LAST:event_butTipoActionPerformed
    
    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        if (ExecSQL.theConn != null)
            try {ExecSQL.theConn.close();
            } catch (SQLException ex) {
                ex.printStackTrace();
            }
        System.exit(0);
    }//GEN-LAST:event_formWindowClosing
    
    private void butExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butExitActionPerformed
        if (ExecSQL.theConn != null)
            try {ExecSQL.theConn.close();
            } catch (SQLException ex) {
                ex.printStackTrace();
            }
        System.exit(0);
    }//GEN-LAST:event_butExitActionPerformed
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton butAdd;
    private javax.swing.JButton butCaratter;
    private javax.swing.JButton butCategoria;
    private javax.swing.JButton butCerca;
    private javax.swing.JButton butDelete;
    private javax.swing.JButton butEdit;
    private javax.swing.JButton butExit;
    private javax.swing.JButton butFigli;
    private javax.swing.JButton butTipo;
    private javax.swing.JButton butZona;
    private javax.swing.JCheckBox chkEventi;
    private javax.swing.JCheckBox chkLivello;
    private javax.swing.JCheckBox chkNote;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JLabel lblMsg;
    private javax.swing.JList lstRicerca;
    private javax.swing.JScrollPane scrRicerca;
    private javax.swing.JTextField txtRicerca;
    // End of variables declaration//GEN-END:variables
    
}